﻿<Window x:Class="C9ShowNotesHelper.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:props="clr-namespace:C9ShowNotesHelper.Properties"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="C9 Show Notes Helper" Height="478" Width="792" Closing="Window_Closing" Loaded="Window_Loaded" Icon="/C9ShowNotesHelper;component/Resources/C9-1-32x32.png" VerticalAlignment="Center" HorizontalAlignment="Center">
    <Grid Name="mainGrid">
    <Grid.Resources>
      <Style TargetType="Separator">
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type Separator}">
              <Border Width="2" Margin="2" Background="Gray"/>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>

      <Style TargetType="ListBox" x:Key="HorizontalListBoxStyle">
        <Setter Property="ItemsPanel">
          <Setter.Value>
            <ItemsPanelTemplate>
              <StackPanel Orientation="Horizontal"
                          VerticalAlignment="Top"
                          HorizontalAlignment="Left"/>
            </ItemsPanelTemplate>
          </Setter.Value>
        </Setter>
      </Style>

    </Grid.Resources>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="12*" />
      <ColumnDefinition Width="111" />
      <ColumnDefinition Width="27" />
      <ColumnDefinition Width="392*" />
      <ColumnDefinition Width="234" />
      <ColumnDefinition Width="14*" />
    </Grid.ColumnDefinitions>
    <Grid.Triggers>
      <EventTrigger RoutedEvent="Button.Click" SourceName="playButton">
        <EventTrigger.Actions>
          <BeginStoryboard Name= "myBegin">
            <Storyboard SlipBehavior="Slip" CurrentTimeInvalidated="MediaTimeChanged">
              <MediaTimeline Name ="test" Storyboard.TargetName="mediaElement1"  />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger.Actions>
      </EventTrigger>
      <EventTrigger RoutedEvent="Button.Click" SourceName="pauseButton">
        <EventTrigger.Actions>
          <PauseStoryboard BeginStoryboardName="myBegin" />
        </EventTrigger.Actions>
      </EventTrigger>
      <EventTrigger RoutedEvent="Button.Click" SourceName="resumeButton">
        <EventTrigger.Actions>
          <ResumeStoryboard BeginStoryboardName="myBegin" />
        </EventTrigger.Actions>
      </EventTrigger>
      <EventTrigger RoutedEvent="Slider.PreviewMouseLeftButtonDown" SourceName="positionSlider">
        <EventTrigger.Actions>
          <PauseStoryboard BeginStoryboardName="myBegin" />
        </EventTrigger.Actions>
      </EventTrigger>
      <EventTrigger RoutedEvent="Slider.PreviewMouseLeftButtonUp" SourceName="positionSlider">
        <EventTrigger.Actions>
          <ResumeStoryboard BeginStoryboardName="myBegin" />
        </EventTrigger.Actions>
      </EventTrigger>

    </Grid.Triggers>
      <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="297*" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="4*" />
    </Grid.RowDefinitions>
    <xctk:BusyIndicator IsBusy="False" BusyContent="Buffering..." Margin="101,48,4,73" Grid.Row="3" Name="bufferingIndicator" IsEnabled="False" Grid.Column="3" />
    <TextBox Name="timecodeTextBox" Grid.Row="5" Grid.ColumnSpan="4" Grid.Column="1" Margin="0,6,0,0" />
    <StackPanel Grid.Row="4" Name="stackPanel1" Orientation="Horizontal" Grid.Column="1" Grid.ColumnSpan="2">
      <Button Height="24" IsEnabled="False" Name="backButton" Width="32" Click="backButton_Click">
        <Image Source="Resources/DoubleLeftArrowHS.png" />
      </Button>
      <Button Height="24" IsEnabled="False" Name="pauseButton" Width="32" Click="pauseButton_Click">
        <Image Source="Resources/PauseHS.png" />
      </Button>
      <Button Height="24" IsEnabled="False" Name="resumeButton" Width="32" Click="resumeButton_Click">
        <Image Source="Resources/Forward.png" />
      </Button>
      <Button Height="24" IsEnabled="False" Name="forwardButton" Width="32" Click="forwardButton_Click">
        <Image Source="Resources/DoubleRightArrowHS.png" />
      </Button>
    </StackPanel>
    <StackPanel Name="stackPanel2" Orientation="Horizontal" Grid.Row="4" Grid.Column="4">
      <Button Content="Get Time Code URL" Height="Auto" IsEnabled="False" Name="timecodeButton" Width="125" Click="timecodeButton_Click" />
      <Label Height="Auto" Name="totalTimeLabel" Width="52" />
      <Label Height="Auto" Name="positionLabel" Width="54" />
    </StackPanel>
    <Slider Name="positionSlider" ValueChanged="positionSlider_ValueChanged" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Row="4" Grid.Column="3" Margin="10,0" />
    <WrapPanel Name="wrapPanel1" Orientation="Horizontal" Grid.ColumnSpan="3" Grid.Column="2" Grid.RowSpan="1">
      <ComboBox Height="Auto" Name="showURLMRUComboBox" IsEditable="True" ItemsSource="{Binding Source={x:Static props:Settings.Default},Path=showMRU}" Text="{Binding Source={x:Static props:Settings.Default},Path=PrimaryURL}" LostFocus="showURLMRUComboBox_LostFocus" Margin="0,2" />
      <Label Name="clearmrulabel">
        <Hyperlink NavigateUri="clearmrulist" RequestNavigate="Hyperlink_RequestNavigate">
          <TextBlock Text="Clear MRU List" />
        </Hyperlink>
      </Label>
      <Label Name="removeselectedlabel">
        <Hyperlink NavigateUri="removeselected" RequestNavigate="Hyperlink_RequestNavigate">
          <TextBlock Text="Remove Selected" />
        </Hyperlink>
      </Label>
      <Label Name="findshowlabel">
        <Hyperlink NavigateUri="findshow" RequestNavigate="Hyperlink_RequestNavigate">
          <TextBlock Text="Find Show" />
        </Hyperlink>
      </Label>
       </WrapPanel>
    <TextBox Name="episodeUrlTextBox" Text="{Binding Source={x:Static props:Settings.Default},Path=EpisodeURL}" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2" Margin="0,2,0,0" />
    <Label Content="Show Episode URL:" Name="episodeUrlLabel" MinWidth="110" Grid.Column="1" Grid.Row="2" />
    <Label Content="Primary Show URL:" Name="showUrlLabel" MinWidth="110" Grid.Column="1" />
    <Label Content="Video URL:" Name="videoUrlLabel" MinWidth="110" MaxWidth="110" Grid.Column="1" Grid.Row="1" />
    <ListBox Grid.Column="1" Grid.ColumnSpan="4" Grid.Row="6" Name="timecodeListBox" Height="110" Style="{StaticResource HorizontalListBoxStyle}" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" Margin="0,4,0,0" MouseDoubleClick="timecodeListBox_MouseDoubleClick" >
      <ListBox.ItemTemplate>
        <DataTemplate>
          <StackPanel Orientation="Horizontal">
            <Image Source="{Binding snapimage}" Height="80" Width="160" />
            <Label Content="{Binding timecodetext}"/>
            <Separator/>
          </StackPanel>
        </DataTemplate>
      </ListBox.ItemTemplate>
      <ListBoxItem>Item 1</ListBoxItem>
      <Separator/>
      <ListBoxItem>Item 2</ListBoxItem>
      <Separator/>
      <ListBoxItem>Item 3</ListBoxItem>
      <Separator/>
      <ListBox.ContextMenu>
        <ContextMenu Name="timecodeContextMenu">
          <MenuItem Header="Copy Timecode HTML" Name="CopyTimeCodeHTML" Click="CopyTimeCodeHTML_Click" />
          <MenuItem Header="Copy Timecode HTML with Thumbnail" Name="CopyTimeCodeThumbnailHTML" Click="CopyTimeCodeThumbnailHTML_Click" />
          <MenuItem Header="Copy Timecode HTML with Thumbnail As TR" Name="CopyTimeCodeThumbnailHTMLTR" Click="CopyTimeCodeThumbnailHTMLTR_Click" />
          <MenuItem Header="Copy All as Table" Name="CopyAllAsTable" Click="CopyAllAsTable_Click" />
          <MenuItem Header="Copy All as C9 DL-DT" Name="CopyAllAsDT" Click="CopyAllAsDLDT_Click" />
          <MenuItem Header="Copy All Timecodes as List" Name="CopyAllTimecodeAsList" Click="CopyAllTimecodeAsList_Click" />
          <MenuItem Header="Jump To" Name="JumpToContentMenu" Click="JumpToContentMenu_Click" />
          <MenuItem Header="Remove" Name="RemoveContentMenu" Click="RemoveContentMenu_Click" />
        </ContextMenu>
      </ListBox.ContextMenu>
    </ListBox>
    <MediaElement Name="mediaElement1"  MediaOpened="mediaElement1_MediaOpened" LoadedBehavior="Manual" UnloadedBehavior="Stop" MediaFailed="mediaElement1_MediaFailed" BufferingStarted="mediaElement1_BufferingStarted" BufferingEnded="mediaElement1_BufferingEnded" Grid.Column="1" Grid.ColumnSpan="4" Grid.Row="3" Margin="0,4" />
    <WrapPanel Grid.Column="2" Grid.ColumnSpan="3" Name="wrapPanel2" Grid.Row="1" Margin="0,4,0,0">
      <TextBox Name="videoUrlTextBox" Text="{Binding Source={x:Static props:Settings.Default},Path=LastUsedVideoURL}" TextWrapping="Wrap"/>
      <Label Name="findepisodelabel">
        <Hyperlink NavigateUri="findepisode" RequestNavigate="Hyperlink_RequestNavigate">
          <TextBlock Text="Find Episode" />
        </Hyperlink>
      </Label>
      <Button Height="24" Name="playButton" Width="32" Click="playButton_Click">
        <Image Source="Resources/PlayHS.png" />
      </Button>
    </WrapPanel>
  </Grid>
</Window>
